module.exports = {
    devServer: {
      before(app){
        app.get('/api/shop/:id', function(req, res) {
            const { id } = req.params
            if (id) {
                res.send({
                    success: true,
                    error: 0,
                    msg: '',
                    data: {
                      title: '个人开发者-马化腾',
                      desc: 'app定制开发、iOS、安卓应用、商城、教育、直播、餐饮',
                      notice: '公告：xxxx 或者其他的东西都行, 不用就注释掉'
                    }
                })
            }
        });

        app.get('/api/commoditys/:id', (req, res) => {

          console.log(
            req.params
          )
          const { id } = req.params
          if (id) {
      
              let list = []
      
              for (let i = 0; i < 20; i++) {
                  let menuId = Math.random()
                  let children = []
                  for (let j = 0; j < Math.floor(Math.random() * 10) + 1; j++) {
                      let title = Math.random()
                      children.push({
                          id: Math.random(),
                          title: title.toString(32),
                          price: (Math.random() * 20).toFixed(2),
                      })
                  }
                  list.push({
                      menu: {
                          id: menuId,
                          title: menuId.toString(32)
                      },
                      children
                  })
              }
              
              res.send({
                  success: true,
                  error: 0,
                  msg: '',
                  data: list
              })
          }

        })

      }
    }
  }
  